package com.sn.campus.dao;

import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.StatementType;

import java.util.HashMap;
import java.util.List;

/**
 * @ProjectName: springboot_socket
 * @Package: com.sn.socket.serviceImpl
 * @ClassName: ${CLASS_NAME}
 * @Author: xiahuihui
 * @Description: ${description}
 * @Date: 2020/5/13 0013 21:02
 * @Version: 1.0
 */
@Mapper
public interface OperationDao {
    @Insert("INSERT into fm_t_realtime_task (id,device_list,command,freq_range,recording_length,detail,create_time,finish_time,creator,file_path) VALUES(null," +
            "#{deviceId},#{command},#{frequency},#{time},null,#{createTime},null,null,null)")
    void insertRealTime(@Param("deviceId") String deviceId, @Param("command") String command, @Param("frequency") String frequency, @Param("time") String time, @Param("createTime") String createTime);

    @Insert("INSERT INTO t_base_device ( id, device_no, device_name, community_name, building_name, device_type, device_address, install_location, device_status," +
            " enable_outserv, month_outserv_count, outserv_endtime, pre_release, registrant, regist_time, cid, intranetip, extranetip, macaddr, tabid, HOST, " +
            "webport, mediaport, mobileport, upnpwebport, upnpmediaport, upnpmobileport, rssi, basedefencestatus, extenddefencestatus ) " +
            "VALUES ( '25aeccb6-cf4e-11ea-a388-00163e003272', '1', NULL, NULL, NULL, 'callhelp', NULL, NULL, '1', NULL, NULL, NULL, NULL, NULL, NULL, " +
            "'2', '127.0.0.1', NULL, '0dfecd0304', NULL, NULL, '9008', '9018', '9028', '8008', '8018', '8028', NULL, '1', '1' ) " +
            " ON DUPLICATE KEY UPDATE device_no = '1'")
    void insertAlarm(@Param("deviceId") String deviceId, @Param("command") String command, @Param("frequency") String frequency, @Param("time") String time, @Param("createTime") String createTime);

    @Insert("INSERT into log (id,device_list,command,freq_range,recording_length,detail,create_time,finish_time,creator,file_path) VALUES(null," +
            "#{deviceId},#{command},#{frequency},#{time},null,#{createTime},null,null,null)")
    void insertLog(@Param("deviceId") String deviceId, @Param("command") String command, @Param("frequency") String frequency, @Param("time") String time, @Param("createTime") String createTime);


    //-----------------------------首页数据接口--------------------------
    @Select({ "call proc_get_index_communities()"})
    @Options(statementType= StatementType.CALLABLE)
    List<HashMap<String,Object>> getIndexCommunities();

    @Select({ "call proc_get_index_top5()"})
    @Options(statementType= StatementType.CALLABLE)
    List<HashMap<String,Object>> getIndexTop5();

    @Select({ "call proc_get_index_totalstat()"})
    @Options(statementType= StatementType.CALLABLE)
    List<HashMap<String,Object>> getIndextotalstat();

    @Select({ "call proc_get_index_top10()"})
    @Options(statementType= StatementType.CALLABLE)
    List<HashMap<String,Object>> getIndexTop10();

    @Select({ "call proc_get_index_device_stat()"})
    @Options(statementType= StatementType.CALLABLE)
    List<HashMap<String,Object>> getIndexDeviceStat();

    @Select({ "call proc_get_index_clock_stat()"})
    @Options(statementType= StatementType.CALLABLE)
    List<HashMap<String,Object>> getIndexClockStat();

    @Select({ "call proc_get_index_sos_device()"})
    @Options(statementType= StatementType.CALLABLE)
    List<HashMap<String,Object>> getIndexSosStat();

    //-----------------------------单个学校数据接口--------------------------
    @Select({ "call proc_get_School_Attends(#{communityno_,mode=IN,jdbcType=VARCHAR})"})
    @Options(statementType= StatementType.CALLABLE)
    List<HashMap<String,Object>> getSchoolAttends(@Param("communityno_") String communityno_);

    @Select({ "call proc_get_School_Temps(#{communityno_,mode=IN,jdbcType=VARCHAR})"})
    @Options(statementType= StatementType.CALLABLE)
    List<HashMap<String,Object>> getSchoolTemps(@Param("communityno_") String communityno_);

    @Select({ "call proc_get_School_MonitorVideo(#{communityno_,mode=IN,jdbcType=VARCHAR})"})
    @Options(statementType= StatementType.CALLABLE)
    List<HashMap<String,Object>> getSchoolMonitorVideo(@Param("communityno_") String communityno_);

    @Select({ "call proc_get_School_SoSVideo(#{communityno_,mode=IN,jdbcType=VARCHAR})"})
    @Options(statementType= StatementType.CALLABLE)
    List<HashMap<String,Object>> getSchoolSosVideo(@Param("communityno_") String communityno_);

}
